package mean.field;
import java.util.Random;
public class MFSimulator {
	int n ; // number of objects
	int beta;// infected rate
	int k; // frequency
	int[] a ;// set of objects
	public static void main(String[] args){
		MFSimulator mfs = new MFSimulator(1000,2,10);
		mfs.infect();
	}
	public MFSimulator(int n, int beta,int k){
		this.n = n;
		this.beta = beta;
		this.k = k;
		
	}
	public int[] infect(){
		a = new int[n];
		a[0]=1; // object[0] is infected 
		//a[i]=0 for all i = 1, 2, ... , n
		int[]count = new int[k+1];
		count[0] = 1; // number of infected nodes
		for(int i = 0;i<k;i++){// run k times
			for (int j = 0;j<beta*count[i];j++){
				Random generator = new Random();
				int rd = generator.nextInt(1000);
				a[rd]=1;
			}
			int ct = 0; // count number of infected objects
			for(int j = 0;j<n;j++){
				if (a[j]==1) ct=ct+1;
			}
			count[i+1] = ct;
		}
		/*for(int i=1;i<k+1;i++){
			System.out.println("# of infected node in "+i+" times is "+ count[i]);
		}*/
		
		return count;
	}
	
}
